package 面试真题;

import java.util.Arrays;
import java.util.Scanner;

public class Ali203 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n-- > 0) {
            int m = scanner.nextInt();
            int[] ints = new int[m];
            for (int i = 0; i < m; i++) {
                ints[i] = scanner.nextInt();
            }
            Arrays.sort(ints);
            int ans = m >= 2 ? ints[0] * (m - 2) : 0;
            for (int i = 1; i < m; i++) {
                ans += ints[i];
            }
            System.out.println(ans);
        }

    }
}
